// 业务统计
import adminLogsService from '@/services/adminlogs/index';

// 定义操作系统占比
async function loadCharts() {
  try {
    var serverResponse = await adminLogsService.stateLogsOSversion();
    var option = {
      title: {
        text: '',
      },

      tooltip: {
        trigger: 'item',
        formatter: '{a} <br/>{b} : {c} ({d}%)'
      },

      legend: {
        orient: 'vertical',
        left: 'left'
      },

      series: [{
        name: '浏览器',
        type: 'pie',
        radius: ['40%', '70%'],
        avoidLabelOverlap: false,
        itemStyle: {
          borderRadius: 10,
          borderColor: '#fff',
          borderWidth: 2
        },
        label: {
          show: false,
          fontSize: 12,
          formatter: '{b} ({d}%)',
          position: 'center'
        },
        emphasis: {
          label: {
            show: true,
            fontSize: '40',
            fontWeight: 'bold'
          }
        },
        labelLine: {
          show: false
        },
        data: serverResponse.data
      }
      ]
    };
    return Promise.resolve(option);
  } catch (e) {
    return Promise.reject(e);
  }
}

export default loadCharts;
